{-
	MyMessages Module
	
	r51
	
	29 March 2010
	
	Daniel De Guzman

	This module is part of the FPT Algorithm Implementation Project for the Massey University
	paper: 159.402 Programming Languages. It contains messages to communicate program status
	or errors and debugging functions for the developer.
-}

module MyMessages where

import Datatypes
import Graph
import Kernelization

-- |=========================================================================================|
-- |									  Output Format										 |
-- |=========================================================================================|

-- Thick border to signify start and end of report 
border :: String
border = "===================================================================\n" 

-- Thin border to signify report sections
tinyBorder :: String
tinyBorder = "-------------------------------------------------------------------\n"

instructions :: String
instructions = border ++ "                      " ++ 
				"FPT Algorithm Implementation\n" ++ tinyBorder ++
				"Type 'quit' to quit.\nEnter name of file:\n "

askSave :: String
askSave = "\nSave output? (Y/N)\n"

enterFileName :: String
enterFileName = "Enter File name:\n"

wrongCmd :: String
wrongCmd = "Invalid command. Exiting program." 
-- |-----------------------------------------------------------------------------------------|

-- |=========================================================================================|
-- |									  Error Messages									 |
-- |=========================================================================================|

-- File Extension Error
errorFileExt :: String
errorFileExt = "Error! Wrong File Extension.\nOnly RTF files allowed for this release.\n"

-- Invalid k value error
errorK :: String
errorK = "Error! Parameter K Invalid or not found.\n"

-- Vertex Count Error
errorVertexCount :: String
errorVertexCount = "Error! Vertex Count Invalid or not found.\n"

-- Specified Vertices Error
errorVertexSpec :: String
errorVertexSpec = "Error! Actual number of vertices invalid.\n"

-- Graph Information Error
errorGInfo :: String
errorGInfo = "Error! Vertex Information invalid.\n"

-- |-----------------------------------------------------------------------------------------|

-- |=========================================================================================|
-- |									  Debug Messages									 |
-- |=========================================================================================|

--
header :: FilePath -> String
header file = border ++ "File name: " ++ file ++ "\n" ++  border

-- Display Graph Creation report
debuggingGraph :: (K, VertexCount, ActualCount, GraphInfo, Graph) -> String
debuggingGraph (k, vc, ac, vInfo, graph)
	=	tinyBorder 						++
		"K: " 							++ k 			++
		"\nVertex Count: " 				++ vc 			++
		"\nActual Number of vertices: " ++ show ac 		++
		"\nVertex Information:\n" 		++ dispGI vInfo ++
		"Created Graph:\n" 				++ dispGC graph

-- Display Kernelized graph report
debuggingKernelization :: Kgraph -> String
debuggingKernelization kernelized
	=	tinyBorder 				++
		"New Parameter K: " 	++ getKernelizedK kernelized 						++
		"\nNew Vertex Count: "	++ 
		show (length (getAllVertices (unzipGraph (getKernelizedGraph kernelized))))	++
		"\nVertex Cover:" 		++ dispVC(getKernelizedVC kernelized) 				++
		"\nKernelized Graph:\n" 	++ dispGC (getKernelizedGraph kernelized)

-- Display the length of the vertex cover and the vertex cover itself
debuggingSearchTree :: VertexCover -> String
debuggingSearchTree vc
	| ((length vc) == 0) 	= "NO"
	| otherwise 			= 	show (length vc) ++ "\n" ++ dispVC vc

-- Display Graph Information
dispGI :: GraphInfo -> String
dispGI [] = ""
dispGI (x:xs) = "  " ++ x ++ "\n" ++ dispGI xs

-- Display Vertex Cover
dispVC :: VertexCover -> String
dispVC [] = ""
dispVC (x:xs) = x ++ " " ++ dispVC xs

-- Display Created Graph
dispGC :: Graph -> String
dispGC [] = "\n"
dispGC (x:xs) 
	= "  " ++ dispLabel x ++ show (dispNbLen x) ++ chooseNb (dispNbLen x) ++ 
		dispNeighbours (getNeighbours x) ++ "\n" ++ dispGC xs
			where
				dispLabel :: GraphEntry -> String
				dispLabel (x,list) = "Vertex " ++ x ++ " has "
	
				dispNeighbours :: Neighbours -> String
				dispNeighbours [] = ""
				dispNeighbours (x:xs) = x ++ " " ++ dispNeighbours xs

				dispNbLen :: GraphEntry -> Int
				dispNbLen (x, list) = length list

				chooseNb :: Int -> String
				chooseNb i 
					| (i == 0) 	= " neigbours."
					| (i == 1) 	= " neighbour, which is: "
					| otherwise	=" neighbours, which are: "

-- |-----------------------------------------------------------------------------------------|
-- |=========================================================================================|